﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel;
using System.Drawing;
using System.Diagnostics;

namespace TextFlow.Activities
{
	public class ActionSequenceActivityDesigner : ActivityDesigner
	{
        private ActionSequenceActivity _sequence;

        public ActionSequenceActivityDesigner()
        {
        }

        protected override void Initialize( Activity activity )
        {
            Debug.Assert( activity is ActionSequenceActivity );

            _sequence = activity as ActionSequenceActivity;

            base.Initialize( activity );
        }

        protected override Size OnLayoutSize( ActivityDesignerLayoutEventArgs e )
        {
            return new Size( 120, 90 );
        }

        protected override void OnPaint( ActivityDesignerPaintEventArgs e )
        {
            StringFormat format = new StringFormat();

            format.Alignment = StringAlignment.Center;

            int textHeight = 15;
            int textY = Location.Y + ( Size.Height / 2 ) - ( textHeight / 2 );

            Rectangle rect = new Rectangle( Location.X, textY, Size.Width, textHeight );

            string action = string.Format( "[{0}]", _sequence.ConfiguredAction );

            Font font = new Font( DesignerTheme.Font, FontStyle.Bold );

            e.Graphics.DrawString( action, font, Brushes.Black, rect, format );

            base.OnPaint( e );
        }
	}
}
